package cn.fu.customTag;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

/**   
* @Title: SkipPageOrEvalPageTag.java 
* @Package cn.fu.customTag 
* @Description: 控制标签后面的内容是否显示
* @author zhangxiaofu   
* @Company www.viewhigh.com
* @date 2016年7月22日 下午11:21:01 
* @version V1.0   
*/
public class SkipPageOrEvalPageTag extends TagSupport{
@Override
public int doEndTag() throws JspException {
	HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
	//只有点击和表单提交才会带此请求头
	String referer = request.getHeader("referer");
	//请求前缀
	String url = "http://"+request.getServerName();
	//判断前缀是否相同
	if(referer != null && referer.startsWith(url)){
		return EVAL_PAGE;
	}else{
		try {
			pageContext.getOut().print("拒绝访问");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return SKIP_PAGE;
	}
	
}
}

